<script type="text/javascript">
    $(document).ready(function() {    
        $("#tags-places").tokenInput( [
            <c:forEach items="${model.places}" var="place">
                {id: "<c:out value="${place.id}"/>", name: "<c:out value="${place.title}"/>"},
            </c:forEach>
                {id: 0, name: ""}
            ], {
                theme: "facebook",
                preventDuplicates: true,
                prePopulate: [
                <c:forEach items="${model.listing.places}" var="place">
                    {id: "<c:out value="${place.id}"/>", name: "<c:out value="${place.title}"/>"},
                </c:forEach>
                ]
            }
        );   

        $("#tags-amenities").tokenInput( [
                <c:forEach items="${model.amenities}" var="amenity">
                    {id: "<c:out value="${amenity.id}"/>", name: "<c:out value="${amenity.title}"/>"},
                </c:forEach>
                {id: 0, name: ""}
            ], {
                theme: "facebook",
                preventDuplicates: true,
                prePopulate: [
                <c:forEach items="${model.listing.amenities}" var="amenity">
                    {id: "<c:out value="${amenity.id}"/>", name: "<c:out value="${amenity.title}"/>"},
                </c:forEach>
                ]
            }
        );    
    });
</script>